// 将文件描述符设置为非阻塞
#pragma once
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include "Log.hpp"

class Util
{
public:
    static bool SetNonBlock(int sock)
    {
        int fl = fcntl(sock, F_GETFL);
        if (fl < 0)
        {
            logMessage(FATAL, "SetNonBlock Error");
            return false;
        }
        fcntl(sock, F_SETFL, fl | O_NONBLOCK);
        return true;
    }
};
